//
//  OtherWayLoginView.m
//  Runner
//
//  Created by Yunxi on 2021/8/30.
//

#import "OtherWayLoginView.h"
#import "DeviceConfig.h"
#import <UmengVertifyPlugin.h>

@implementation OtherWayLoginView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self setUpView];
    }
    return self;
}

- (void)setUpView {
    
    UIButton *appleLogBtn = [self makeButtonWithIcon:@"apple" frame:CGRectMake((self.center.x-21), 0, 42, 42)];
    [appleLogBtn addTarget:self action:@selector(appleLogin) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:appleLogBtn];
    
    UIButton *phoneNumberBtn = [self makeButtonWithIcon:@"phone" frame:CGRectMake((appleLogBtn.frame.origin.x-59*ScaleW-42), 0, 42, 42)];
    [phoneNumberBtn addTarget:self action:@selector(phoneNumberLogin) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:phoneNumberBtn];
    
    UIButton *wechatBtn = [self makeButtonWithIcon:@"wechat" frame:CGRectMake((appleLogBtn.frame.origin.x+42+59*ScaleW), 0, 42, 42)];
    
    [wechatBtn addTarget:self action:@selector(wechatLogin) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:wechatBtn];
    
}

- (UIButton *)makeButtonWithIcon:(NSString *)iconName frame:(CGRect)buttonFrame{
    UIButton *button = [[UIButton alloc] initWithFrame:buttonFrame];
    [button setBackgroundImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
    
    return button;
}

- (void)appleLogin {
    NSLog(@"苹果登录--");
    
    [UmengVertifyPlugin clickOtherLogin:Apple];
}

- (void)phoneNumberLogin {
    NSLog(@"手机号登录--");
    [UmengVertifyPlugin clickOtherLogin:PhoneNumber];

}

- (void)wechatLogin {
    NSLog(@"微信登录--");

    [UmengVertifyPlugin clickOtherLogin:Wechat];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
